//
//  HomeViewController.swift
//  SWfanghu
//
//  Created by 李言 on 16/6/6.
//  Copyright © 2016年 ly. All rights reserved.
//

import UIKit

class HomeViewController: BaseviewController {

    // MARK: 评房按钮
    private var pingfangBut: UIButton!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.navigationBar.hidden = true

        let bannerH = frameSize.width*720/1242
        let banner = UIImageView(frame: CADipRectMake(0, 0, frameSize.width, bannerH))
        banner.image = UIImage(named: "banner")
        view.addSubview(banner)
        
        let iconX = frameSize.width / 3 / 2 - 150/2
        var Y = bannerH + 40
        let texts = ["一二三四","一二三四","一二三四"]
        for i in 0..<3 {
            let icon = UIImageView(image: UIImage(named: "home_icon\(i)"))
            icon.frame = CADipRectMake(iconX+CGFloat(i)*frameSize.width/3, Y, 150, 150)
            view.addSubview(icon)
            
            let line = UIView(frame: CADipRectMake(frameSize.width/3*CGFloat(i), bannerH+20, 2, 150+70))
            line.backgroundColor = color_line
            view.addSubview(line)
        
            let info = UILabel(frame: CADipRectMake(CGFloat(i)*frameSize.width/3, Y+150, frameSize.width/3,30))
            info.textAlignment = .Center
            info.text = texts[i]
            info.font = UIFont.systemFontOfSize(12)
            view.addSubview(info)
            
        }
        
        Y += 150+90
        pingfangBut = addButton(CADipRectMake(40, Y, frameSize.width - 80, 88), tittle: "极速评房", target: self, action: #selector(HomeViewController.pushBut))
        view.addSubview(pingfangBut)
        
        Y += 88+16
        let textcolor = UIColor(red: 120/255.0, green: 120/255.0, blue: 163/255.0, alpha: 1)
        let lab = UILabel(frame: CADipRectMake(0, Y, frameSize.width, 20))
        lab.textAlignment = .Center
        lab.text = "最快立即返回房价"
        lab.font = UIFont.systemFontOfSize(12)
        lab.textColor = textcolor
        view.addSubview(lab)
        
        Y += 100
        // TODO: 根据接口修改
        let lab2 = UILabel(frame: CADipRectMake(0, Y, frameSize.width, 100))

        lab2.textAlignment = .Center
        lab2.numberOfLines = 3        
        lab2.text = "一次评房，终身有效，额度随时使用\n最快2天放款\n保证资金供应充裕"
        lab2.font = UIFont.systemFontOfSize(12)
        lab2.textColor = textcolor
        view.addSubview(lab2)
        
        Y+=130
        let kefu = UILabel(frame:CADipRectMake(0, Y, frameSize.width, 30))
        kefu.textAlignment = .Center
        kefu.text = "客服电话：18414141414141"
        kefu.textColor = textcolor
        kefu.font = UIFont.systemFontOfSize(12)
        view.addSubview(kefu)
    }

    func pushBut(){
        let vc = PingfangViewController()
        vc.title = "评房"
        navigationController?.pushViewController(vc, animated: true)
    }
}
